package com.bilibili.server.repository;

import com.bilibili.server.entity.Category;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface CategoryRepository extends JpaRepository<Category, Integer> {
    Optional<Category> findByName(String name);
    Optional<Category> findByAlias(String alias);
    List<Category> findByParentId(Integer parentId);
    List<Category> findByStatus(Integer status);
    List<Category> findByLevel(Integer level);
    List<Category> findByLevelAndStatus(Integer level, Integer status);

    List<Category> findByParentIdIsNullAndStatusOrderBySortOrderAsc(Integer status);
}